<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>差错说明填写</title>
	<!-- <script type="text/javascript" src="../js/jquery-2.2.3.min.js"></script> -->
    <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>

<!-- 你的HTML代码 -->

<script src="../layui/layui.js"></script>
<input id="hidValue" type="hidden">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">货物名称</label>
        <div class="layui-input-block">
            <input type="text" name="goodsName" required  lay-verify="required" placeholder="货物名称" autocomplete="off" class="layui-input" style="width:30%;height:40px">
        </div>
    </div>
	
	<div class="layui-form-item">
	            <label class="layui-form-label">货物差错说明</label>
	            <div class="layui-input-block">
	                <textarea id="mistakeExplain" name="mistakeExplain" required  lay-verify="required" placeholder="货物差错说明:" type="text/plain" style="width:70%;height:200px"></textarea>
	           </div>
	 </div>
	 <div class="layui-form-item">
	    <label class="layui-form-label">上传信息（图片文件）</label>
	    <div class="layui-input-block">
	        <input type="file" name="file" required  lay-verify="required"  autocomplete="off" >
	    </div>
	</div>
	

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>

<script>
	
	
	
    layui.use('form', function(){
		var $=layui.$;
		
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
			 var mydata = new FormData();
			 mydata.append("goodsName",data.field.goodsName);
			 mydata.append("mistakeExplain",data.field.mistakeExplain);
			  mydata.append("num",$("#hidValue").val());
			 mydata.append("file",$("[name=file]")[0].files[0]);
			$.ajax({
				url:"http://localhost:9000/arrival/saveArriveError",
				type:"post",
				processData:false,
				contentType:false,
				data:mydata,
				success:function(data){
					if(data.code=="0"){
						layer.msg(data.msg,{
							icon: 1,
						     time: 3000 
						})
						setTimeout(function() {
					           location.reload();
					            parent.location.reload();
					        }, 2000);
						//location.reload();
					}else{
						layer.msg(data.msg,{
							icon: 1,
						     time: 3000 
						})
						setTimeout(function() {
						       location.reload();
						        parent.location.reload();
						    }, 2000);
					}
				}
			})
			 return false;
        });
    });
</script>
</body>
</html>
